﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Common
{
    /// <summary>
    /// A user update category ("topic")
    /// </summary>
    [Serializable]
    public class Category
    {
        public string Name;
        public List<string> Queries;
        public List<UpdateTime> UpdateTimes;
        public List<DomainPriority> DomainPriorities = new List<DomainPriority>();
        public List<Document.Type> DocumentTypes;
        public bool UpdateRealTime;

        public bool IsDocumentTypeRequested(Document.Type Type)
        {
            return DocumentTypes.Contains(Type);
        }

        public int GetPriorityBySiteName(string siteName)
        {
            foreach (DomainPriority dp in DomainPriorities)
                if (dp.SiteName == siteName)
                    return dp.Priority;
            return 0;
          
        }

        public override string ToString()
        {
            return Name;
        }
    }
    [Serializable]
    public class UpdateTime
    {
        public DayOfWeek Day;
        public TimeSpan Hour;

        public UpdateTime(DayOfWeek day, TimeSpan hour)
        {
            Day = day;
            Hour = hour;
        }

        public UpdateTime()
        {
        }

        public override string ToString()
        {
            return (System.Globalization.DateTimeFormatInfo.CurrentInfo).DayNames[(int)Day] + " " + DateTime.MinValue.Add(Hour).ToString("HH:mm");
        }
    }

    
}
